<?php

namespace app\admin\model\order;

use think\Model;


class OrderStatement extends Model
{

    

    

    // 表名
    protected $table = 'order_statement';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'integer';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'statement_type_text'
    ];
    

    
    public function getStatementTypeList()
    {
        return ['order' => __('Statement_type order'), 'aftersales' => __('Statement_type aftersales')];
    }


    public function getStatementTypeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['statement_type']) ? $data['statement_type'] : '');
        $list = $this->getStatementTypeList();
        return isset($list[$value]) ? $list[$value] : '';
    }




    public function user()
    {
        return $this->belongsTo('app\admin\model\User', 'user_id', 'id',[],'Left')->setEagerlyType(0);
    }


    public function order()
    {
        return $this->belongsTo('app\admin\model\order\Order', 'order_id', 'id',[],'Left')->setEagerlyType(0);
    }


    public function refund()
    {
        return $this->belongsTo('app\admin\model\order\OrderRefund', 'refund_order_id', 'id',[],'Left')->setEagerlyType(0);
    }
}
